import javafx.util.Pair;

import java.util.Arrays;
import java.util.HashSet;

/**
* @description: 893. 特殊等价字符串组
* @author hewei
* @date 2022/9/15 16:38
* @version 1.0
*/

public class NumSpecialEquivGroups {

    public int numSpecialEquivGroups(String[] words) {
        HashSet<Pair<String, String>> set = new HashSet<>();
        for (String word : words) {
            char[] ou = new char[word.length() / 2];
            char[] ji = new char[word.length() - ou.length];
            for (int i = 0; i < word.length(); i++) {
                if (i % 2 == 0) {
                    ji[i / 2] = word.charAt(i);
                } else {
                    ou[(i - 1) / 2] = word.charAt(i);
                }
            }
            Arrays.sort(ou);
            Arrays.sort(ji);
            set.add(new Pair<>(new String(ji), new String(ou)));
        }
        return set.size();
    }
}
